package com.java.struts.order.service;

import com.java.struts.base.exception.BusinessException;
import com.java.struts.order.dao.OrderDao;
import com.java.struts.order.entity.OrderinfoEntity;

import java.util.List;

public class OrderService {

    private OrderDao orderDao = new OrderDao() ;

    /**
     * 查询订单
     * @return
     */
    public List<OrderinfoEntity> listOrders(){
        List<OrderinfoEntity> listOrder = (List<OrderinfoEntity>)orderDao.listType();
        if(listOrder.size()<1){
            throw  new BusinessException("没有查询到订单");
        }
        return listOrder;
    }

    /**
     * 添加订单
     * @param orderInfo
     */
    public void addOrder(OrderinfoEntity orderInfo){
        orderDao.addOrder(orderInfo);
    }

    /**
     * 删除订单信息
     * @param orderId
     */
    public void delOrder(Integer orderId){
        orderDao.deleteOrder(orderId);
    }

    /**
     * 修改订单信息
     * @param orderInfo
     */
    public void updateOrder(OrderinfoEntity orderInfo){
        orderDao.updateType(orderInfo);
    }
}
